package me.spring.cloud.common.components.response.util;

import me.spring.cloud.common.components.response.service.BaseRespService;
import me.spring.cloud.common.components.rpc.response.CommonResponse;
import me.spring.cloud.common.components.util.enums.CodedEnum;

/**
 * @description: 反馈数据工具类
 * @author: luffy
 * @create: 2018-07-31 13:17
 **/
public class CommonResponseUtil {

  private static BaseRespService respService = new BaseRespService();

  public static <T> CommonResponse<T> success() {
    return respService.success();
  }

  public static <T> CommonResponse<T> success(T t) {
    return respService.success(t);
  }

  public static <T> CommonResponse<T> error() {
    return respService.error();
  }

  public static <T> CommonResponse<T> error(CodedEnum codedEnum) {
    return respService.error(codedEnum);
  }

  public static <T> CommonResponse<T> error(CodedEnum codedEnum,String message) {
    return respService.error(codedEnum.getCode(),message);
  }

  public static <T> CommonResponse<T> error(Object code) {
    return respService.error(code);
  }

  public static <T> CommonResponse<T> errorBody(T body) {
    return respService.error(body);
  }

  public static <T> CommonResponse<T> error(String message) {
    return respService.error(message);
  }

  public static <T> CommonResponse<T> error(Object code, String message) {
    return respService.error(code, message);
  }
}
